home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_rmtp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.4 KB  |  61 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5. /* #include <cdrfrb.h> */
  6.  
  7. #ifdef DEBUG
  8. main(int argc, char *argv[])
  9. {
  10.     struct TIMEADRS time, end_time;
  11.     
  12.     printf("return is %x\n", cdr_rmtplay(0, &time, &end_time));
  13.     printf("start %d分 %d秒 %dフレーム\n", time.min, time.sec, time.frame);
  14.     printf("end   %d分 %d秒 %dフレーム\n", end_time.min, end_time.sec, end_time.frame);
  15.  
  16. }
  17. #endif
  18.  
  19. /* 音楽演奏情報の読み取り(時間指定) */
  20. /*
  21.  * decice_no:   device number (Towns CD-ROM -> 0)
  22.  * start_time: 演奏開始時間
  23.  * end_time: 演奏終了時間
  24.  * return: 0 -> 正常終了, 0以外 -> エラー
  25.  */
  26. int cdr_rmtplay(int device_no, struct TIMEADRS *start_time, struct TIMEADRS *end_time)
  27. {
  28.     union REGS reg;
  29.     struct SREGS seg;
  30.     char buf[6];
  31.     
  32.     reg.h.ah = 0x51;
  33.     reg.h.al = (0xC0 | (u_char) device_no);
  34.     reg.x.cx = 0x0001;
  35.  
  36.     reg.x.di = (u_int) buf;
  37.     segread(&seg);
  38.     seg.ds = seg.ss;
  39.  
  40.     int86x(0x93, ®, ®, &seg);
  41.     
  42.     if (start_time) {
  43.         start_time->min = buf[0];    /* 分 */
  44.         start_time->sec = buf[1];    /* 秒 */
  45.         start_time->frame = buf[2];    /* フレーム */
  46.     }
  47.     if (end_time) {
  48.         end_time->min = buf[3];    /* 分 */
  49.         end_time->sec = buf[4];    /* 秒 */
  50.         end_time->frame =buf[5];    /* フレーム */
  51.     }
  52.     if (reg.h.ah == 0) {
  53.         return 0;
  54.     } else if (reg.h.ah == 0x02) {  /* device number error */
  55.         return DEVERR;
  56.     } else {                        /* (reg.h.ah == 0x80) hard ware error */
  57.         return reg.x.cx;
  58.     }
  59. }
  60.  
  61.